﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;

public class Ban1GetMyMoveAction : MonoBehaviour
{
    public SteamVR_Action_Vector2 moveAction = 
        SteamVR_Input.GetAction<SteamVR_Action_Vector2>("platformer","Move");

    public SteamVR_Action_Boolean jumpAction = 
        SteamVR_Input.GetAction<SteamVR_Action_Boolean>("platformer", "Jump");

    public SteamVR_Action_Boolean grabAction =
        SteamVR_Input.GetAction<SteamVR_Action_Boolean>("platformer", "GrabPinch");

    void Update()
    {
//         if (moveAction != null && moveAction.GetChanged(SteamVR_Input_Sources.Any))
//         {
//             Vector2 pos = moveAction.GetAxis(SteamVR_Input_Sources.Any);
//             Debug.Log("手柄的触摸屏坐标为:" +pos);
//         }
// 
//         if(jumpAction!=null && jumpAction.GetStateDown(SteamVR_Input_Sources.Any))
//         {
//             Debug.LogWarning("手柄的触摸屏被按下");
//         }
// 
//         if (grabAction != null && grabAction.GetStateDown(SteamVR_Input_Sources.Any))
//         {
//             Debug.LogError("手柄的扳机被按下");
//         }
    }

    /// <summary>
    /// 获得用户在触摸面板上触摸的位置.
    /// </summary>
    /// <returns></returns>
    public Vector2 GetMoveAxis()
    {
        Vector2 pos = Vector2.zero;
        if (moveAction != null && moveAction.GetChanged(SteamVR_Input_Sources.Any))
        {
            pos = moveAction.GetAxis(SteamVR_Input_Sources.Any);
        }

        return pos;
    }
}
